﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CRM.Entity;
using CRM.BLL;
using DP.Web.UI;
using DP.Web.UI.Controls;
using DP.Common;
using FredCK.FCKeditorV2;

namespace CRM.Web.FaqManage
{
    public partial class FaqDetialView : Common.PageBase
    {
        T_FAQ_SRC_BLL dal = new T_FAQ_SRC_BLL();
        T_USER_BLL userBll = new T_USER_BLL();
        public string _SRCID = "";

        private UserLoginInfo _loginInfo;
        protected override void OnInit(EventArgs e)
        {
            base.VerificationRight = false;
            base.OnInit(e); 
            UserLoginInfo.CheckLoginInfo();
            _loginInfo = UserLoginInfo.GetLoginInfo();
            PageHelper.SetPrePageUrl(this.Page);
            PageHelper.SetGoBackUrl(this.Page, btnCancel, StaticConstant.NotBackUrl);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _SRCID = PageHelper.GetQueryString(this.Page, "SRCID");
                pageDataInit();
            }
        }

        private void pageDataInit()
        {
            T_FAQ_SRC_Entity entity = new T_FAQ_SRC_Entity();
            entity = dal.GetEntity("SRCID", _SRCID);
            if (entity != null)
            {
                this.lbSRCTITLE.Text = entity.SRCTITLE;
                this.lblSRCCONTENT.Text = entity.SRCCONTENT;
                this.hlATTACHFILE.NavigateUrl = entity.ATTACHFILE;
                this.hlATTACHFILE.Text = GetFileName(entity.ATTACHFILE);
                this.lblSRCKEY.Text = entity.SRCKEY;
                lblUserName.Text = userBll.GetCacheUserNameByUserId(this.Page, entity.USERID.ToString());

                entity.SRCHITNUM = entity.SRCHITNUM + 1;
                dal.Update(entity);
            }
            else
            {
 
            }
            this.lblTitle.Text = "FAQ 内容 >> " + PageHelper.GetQueryString(this.Page, "CATNAME");
        }


        /// <summary>
        /// 在绝对路径中，获取Excel文件名
        /// </summary>
        /// <param name="input">需要导入的Excel绝对路径</param>
        /// <returns></returns>
        private string GetFileName(string input)
        {
            return input.Substring(input.LastIndexOf("\\") + 1);
        }
    }
}
